#!/bin/bash
# RK3588视频流客户端启动脚本

# 屏蔽内核MIPI错误日志
echo 3 > /proc/sys/kernel/printk 2>/dev/null || true

echo "[启动] RK3588硬件编码视频流测试客户端"
echo "========================================="

# 基础环境检查
echo "[检查] 环境检查..."

if [ ! -e "/dev/video41" ]; then
    echo "[错误] 摄像头设备不存在"
    exit 1
fi

if ! command -v gst-launch-1.0 >/dev/null 2>&1; then
    echo "[错误] GStreamer未安装" 
    echo "请运行: sudo apt install gstreamer1.0-tools gstreamer1.0-plugins-*"
    exit 1
fi

echo "[成功] 基础环境检查完成"

# 设置权限并清理
chmod 666 /dev/video41 2>/dev/null
pkill -f "gst-launch" >/dev/null 2>&1

echo "[启动] 启动视频流客户端..."
exec python3 rk3588_client.py 192.168.233.187 9000